home *** CD-ROM | disk | FTP | other *** search
- Path: taco.cc.ncsu.edu!boyle
- From: boyle@laue.chem.ncsu.edu (Paul D. Boyle)
- Newsgroups: comp.lang.c
- Subject: Re: How do I use abs() on floats ?
- Date: 22 Feb 1996 14:17:51 GMT
- Organization: North Carolina State University
- Message-ID: <4ghtuf$u5h@taco.cc.ncsu.edu>
- References: <4ghki0$b44@LNCSEX0003.eu.btco.com>
- NNTP-Posting-Host: laue.chem.ncsu.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- DaveMx wrote:
- : What's the easiest way to get the absolute scalar value of a float.
- : I need to test to see of a variable is 'bigger' than a certain tolerance.
-
- : e.g.
-
- : if ( abs (error__float) > MAX_TOLERANCE ) printf ( "Tolerance level
- exceeded \n" );
-
-
- : BUT the abs() function says it only works on int 's . Any ideas how to do
- : it for floats in the most elegant way ???
-
- Try the fabs() function
- #include <math.h>
-
- Prototype: double fabs( double x );
-
- Later,
-
- Paul
-
- __
- Paul D. Boyle | boyle@laue.chem.ncsu.edu
- Director, X-ray Structural Facility | phone: (919) 515-7362
- Department of Chemistry - Box 8204 | FAX: (919) 515-5079
- North Carolina State University |
- Raleigh, NC, 27695-8204
- http://laue.chem.ncsu.edu/web/xray.welcome.html
-
-